<?
if(isset($var_name) && isset($var_value)){
    if($var_name!="" && $var_value!=""){
	preg_match("!^(.+?)_(.+?)$!ie",$var_name, $match);
	$file=file("/etc/asterisk/modules.conf");
	$tmp=0;
	if($var_value=="auto"){
	    foreach($file as $i=>$ii){
		if(preg_match("!$match[2]!", $ii)){array_splice($file, $i, 1);}
	    }
	}
	if($var_value=="noload"){
	    foreach($file as $i=>$ii){
		if(preg_match("!$match[2]!", $ii)){
		    array_splice($file, $i, 1,"noload => $match[2]\n");
		    $tmp=1;	    
		}
	    }
	    if($tmp==0){
		array_splice($file, -1, 1, "noload => $match[2]\n");
		array_push($file, "[global]\n");
	    }
	}
	if($var_value=="load"){
	    foreach($file as $i=>$ii){
		if(preg_match("!$match[2]!", $ii)){
		    array_splice($file, $i, 1,"load => $match[2]\n");
		    $tmp=1;
		}
	    }
	    if($tmp==0){
		array_splice($file, -1, 1, "load => $match[2]\n");
		array_push($file, "[global]\n");	    
	    }
	}
	$f=@fopen("/etc/asterisk/modules.conf", "w");
	foreach($file as $i)
	    @fwrite($f, $i);
	@fclose($f);
    }
}
?>